/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.chalmers.se.tda367.main;

import edu.chalmers.se.tda367.model.User;
import edu.chalmers.se.tda367.observer.GlobalObserverList;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JPanel;

/**
 *
 * @author pierrereimertz
 */
public class Pluggis {

    private static GlobalObserverList observers = GlobalObserverList.getInstance();
    private static final Pluggis INSTANCE = new Pluggis();
    private User selectedUser;
    private User oldUser;
    private JPanel mainViewPanel = null;

    private Pluggis() {
    }

    public JPanel getMainView() {
        return mainViewPanel;
    }

    public void setMainViewPanel(JPanel m) {
        if (mainViewPanel == null) {
            mainViewPanel = m;
        }
    }

    public User getSelectedUser() {
        return selectedUser;
    }

    public void setSelectedUser(User u) {
        if (selectedUser != u) {

            oldUser = selectedUser;
            selectedUser = u;

            GlobalObserverList.getInstance().firePropertyChange("GUI.SelectedUserChanged", oldUser, selectedUser);
        }
    }

    public static void repaintViews() {
        observers.firePropertyChange("GUI.RepaintView", null, null);
    }

    public static Pluggis getInstance() {

        return INSTANCE;
    }
}
